import React, {  Component } from 'react'
import { Route, Switch, Redirect, withRouter } from 'react-router-dom';
import {  observer } from 'mobx-react'

@observer
class LRouter extends Component{

    render(){
        
        const { conf } = this.props

        return(

            <div>
                <Switch>
                    
                    {
                        conf.map(item =>{

                            if(item.redirect){
                                return ( <Redirect key={item.path} {...item} to={item.redirect} /> )
                            }else{
                                return ( <Route key={item.path} {...item}  />  )
                            }

                        })
                    }
                    
                </Switch>
            </div>


        )
        
    }
    
}

export default withRouter(LRouter) 